import { createHashRouter, Navigate } from 'react-router-dom'

import Layout from '@/layout'

import Login from '@/views/Login'
import Home from '@/views/Home'
import BookList from '@/views/BookList'
import DynamicMediumList from '@/views/DynamicMediumList'
import NestedList from '@/views/NestedList'
import BookDetail from '@/views/BookDetail'
import LargeFrequentList from '@/views/LargeFrequentList'

const routes = [
  {
    path: '',
    element: <Navigate to="/home" />
  },
  {
    path: '/login',
    name: 'Login',
    element: <Login />,
    meta: {
      title: '用户登录',
      requiresAuth: false
    }
  },
  {
    path: '/',
    element: <Layout />,
    children: [
      {
        path: 'home',
        name: 'Home',
        element: <Home />,
        meta: {
          title: '首页',
          requiresAuth: true
        }
      },
      {
        path: 'books',
        name: 'Books',
        element: <BookList />,
        meta: {
          title: '图书目录管理',
          requiresAuth: true
        }
      },
      {
        path: 'inventory',
        name: 'Inventory',
        element: <DynamicMediumList />,
        meta: {
          title: '库存管理',
          requiresAuth: true
        }
      },
      {
        path: 'catalog',
        name: 'Catalog',
        element: <NestedList />,
        meta: {
          title: '分类管理',
          requiresAuth: true
        }
      },
      {
        path: 'book/:id',
        name: 'BookDetail',
        element: <BookDetail />,
        meta: {
          title: '图书详情',
          requiresAuth: true
        }
      },
      {
        path: 'order',
        name: 'Order',
        element: <LargeFrequentList />,
        meta: {
          title: '订单处理',
          requiresAuth: true
        }
      },
    ]
  },




]

export default createHashRouter(routes)
